{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:abc\n",
      "1:def\n",
      "2:hij\n"
     ]
    }
   ],
   "source": [
    "lines = [\"abc\",\"def\",\"hij\"]\n",
    "for i in range(len(lines)):\n",
    "    print(f\"{i}:{lines[i]}\")\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "comment_index:10\n",
      "line=int a = 2;\n",
      "comment:/*abcd\n"
     ]
    }
   ],
   "source": [
    "line = \"int a = 2;/*abcd\"\n",
    "comment_index = line.find(\"/*\")\n",
    "print(f\"comment_index:{comment_index}\")\n",
    "if comment_index > -1:\n",
    "    comment = line[comment_index:]\n",
    "    line = line[0:comment_index]\n",
    "    print(f\"line={line}\")\n",
    "    comment_start = True\n",
    "    \n",
    "    print(f\"comment:{comment}\")\n",
    "    comment_index = line.find(\"*/\")\n",
    "    if comment_index > -1:\n",
    "        comment_start= False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "line=do/*/ Memory.deAlloc(this);   return; \n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "line = \"do/*/ Memory.deAlloc(this); /** 注释 */ return;/* 又是注释*/\"\n",
    "line = re.sub(\"\\/\\*\\*?[^*]+\\*\\/\", \" \", line)\n",
    "print(f\"line={line}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
